home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / delphi / kolekce / d6 / rxlibsetup.exe / {app} / units / STR16.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  2002-02-19  |  2.4 KB  |  107 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {         Delphi VCL Extensions (RX)                    }
  4. {                                                       }
  5. {         Copyright (c) 2001,2002 SGB Software          }
  6. {         Copyright (c) 1997, 1998 Fedor Koshevnikov,   }
  7. {                        Igor Pavluk and Serge Korolev  }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Str16;
  12.  
  13. interface
  14.  
  15. {$IFNDEF WIN32}
  16.  
  17. {$I RX.INC}
  18.  
  19. type
  20.   ShortString = string;
  21.   PShortString = ^ShortString;
  22.   AnsiChar = Char;
  23.   PAnsiChar = ^AnsiChar;
  24.  
  25. { System32 unit functions and procedures }
  26. procedure SetLength(var S: string; NewLength: Byte);
  27. procedure SetString(var S: string; Buffer: PChar; Len: Byte);
  28. procedure UniqueString(var S: string);
  29.  
  30. { SysUtils32 unit functions and procedures }
  31. function Trim(const S: string): string;
  32. function TrimLeft(const S: string): string;
  33. function TrimRight(const S: string): string;
  34. function QuotedStr(const S: string): string;
  35.  
  36. {$ENDIF WIN32}
  37.  
  38. implementation
  39.  
  40. {$IFNDEF WIN32}
  41.  
  42. uses SysUtils;
  43.  
  44. procedure SetLength(var S: string; NewLength: Byte);
  45. begin
  46.   S[0] := Char(NewLength);
  47. end;
  48.  
  49. procedure SetString(var S: string; Buffer: PChar; Len: Byte);
  50. begin
  51.   S[0] := Char(Len);
  52.   if Buffer <> nil then begin
  53.     if StrLen(Buffer) < Len then Len := StrLen(Buffer);
  54.     Move(Buffer^, S[1], Len);
  55.   end;
  56. end;
  57.  
  58. procedure UniqueString(var S: string);
  59. begin
  60. end;
  61.  
  62. function Trim(const S: string): string;
  63. var
  64.   I, L: Byte;
  65. begin
  66.   L := Length(S);
  67.   I := 1;
  68.   while (I <= L) and (S[I] <= ' ') do Inc(I);
  69.   if I > L then Result := ''
  70.   else begin
  71.     while S[L] <= ' ' do Dec(L);
  72.     Result := Copy(S, I, L - I + 1);
  73.   end;
  74. end;
  75.  
  76. function TrimLeft(const S: string): string;
  77. var
  78.   I, L: Byte;
  79. begin
  80.   L := Length(S);
  81.   I := 1;
  82.   while (I <= L) and (S[I] <= ' ') do Inc(I);
  83.   Result := Copy(S, I, 255);
  84. end;
  85.  
  86. function TrimRight(const S: string): string;
  87. var
  88.   I: Byte;
  89. begin
  90.   I := Length(S);
  91.   while (I > 0) and (S[I] <= ' ') do Dec(I);
  92.   Result := Copy(S, 1, I);
  93. end;
  94.  
  95. function QuotedStr(const S: string): string;
  96. var
  97.   I: Byte;
  98. begin
  99.   Result := S;
  100.   for I := Length(Result) downto 1 do
  101.     if Result[I] = '''' then Insert('''', Result, I);
  102.   Result := '''' + Result + '''';
  103. end;
  104.  
  105. {$ENDIF WIN32}
  106.  
  107. end.